package cn.com.ejiakanghu.core.rabbitmq.promotemq;

import cn.com.ejiakanghu.core.config.DirectExchangeRabbitMQConfig;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author huangfei
 * @create 2022-01-24 14:28
 */
@Configuration
public class WxCashRabbitConfig {

    @Bean
    public Queue TestDirectQueue() {
        return new Queue(DirectExchangeRabbitMQConfig.USER_WX_WITHDRAWAL_QUEUE,true);
    }

    @Bean
    DirectExchange TestDirectExchange() {
        return new DirectExchange(DirectExchangeRabbitMQConfig.DIRECT_EXCANGE_NAME,true,false);
    }

    //绑定  将队列和交换机绑定, 并设置用于匹配键：TestDirectRouting
    @Bean
    Binding bindingDirect() {
        return BindingBuilder.bind(TestDirectQueue()).to(TestDirectExchange()).with(DirectExchangeRabbitMQConfig.USER_WX_DIRECTROUTING);
    }

    @Bean
    DirectExchange lonelyDirectExchange() {
        return new DirectExchange("lonelyDirectExchange");
    }
}
